package my.jwds.p171;

public class TitleToNumber {
    public static void main(String[] args) {
        TitleToNumber o = new TitleToNumber();
        System.out.println(o.titleToNumber("AB"));
    }

    public int titleToNumber(String columnTitle) {
        int res=0,factor=1,length=columnTitle.length();
        for (int i = length-1; i >= 0; i--) {
            res += factor*(columnTitle.codePointAt(i)-64);
            factor*=26;
        }
        return res;
    }
}
